import { animation } from "@/utils";
import { View, Button, Image } from "@tarojs/components";
import { useState } from "react";

export default function Index() {
  const [count, setCount] = useState(0);

  const onClick = () => {
    animation({
      from: 0,
      to: 100,
      duration: 1000,
      onUpdate(v) {
        setCount(parseFloat(v.toFixed(2)));
      },
    });
  };

  return (
    <View className="p-4">
      <Button type="primary" className="p-2" onClick={onClick}>
        播放{count}
      </Button>

      <View className="flex">
        <Image
          className="w-10 h-10"
          src={require("@/as/icon_ai_voice_on.png")}
        />
        <Image
          className="w-10 h-10"
          src={require("@/as/icon_ai_voice_off.png")}
        />
      </View>
    </View>
  );
}

// usePullDownRefresh(() => {
//   console.log("开始刷新...");
//   // 模拟异步加载数据
//   setTimeout(() => {
//     Taro.stopPullDownRefresh({
//       success: (res) => {
//         console.log("停止刷新成功", res);
//       },
//     });
//   }, 2000);
// });
